﻿<?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''): ?>
<?php get_header(); ?>				   
<div id="accordion">
    <?php include_once (TEMPLATEPATH . '/inc/menu-home.php' ); ?>
    <?php include_once (TEMPLATEPATH . '/inc/menu-news.php' ); ?>
    <div class="panel active hasdata">
		<div class="pink work-menu" rel="pushstate"></div>
		<div class="panelContent p3">
<?php endif; ?>
        <?php include_once (TEMPLATEPATH . '/inc/language-nav.php' ); ?>
		<?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''): ?>
			<div class="container-860"><?php endif; ?>		
				<section class="into-work">
					<h1>WORK</h1>
					<?php include_once (TEMPLATEPATH . '/inc/sticky-nav.php' ); ?>
					<div class="content">
					<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
					<?php
						$work_photo 		= get_post_meta(get_the_ID(), 'work_photo', true);
						$photo_desc			= get_post_meta(get_the_ID(), 'slideshow_description', true);
						$work_field 		= get_post_meta(get_the_ID(), 'info-work-field', true);	
						$work_value 		= get_post_meta(get_the_ID(), 'info-work-value', true);	
						$supersized 		= get_post_meta(get_the_ID(), 'bg-supersized', true);	
						$subtitle 			= get_post_meta(get_the_ID(), 'work-subtitle', true);	
						
						$slides = array();
						if($supersized != NULL && !empty($supersized)):
							foreach($supersized as  $photo_id)
								$slides[] = wp_get_attachment_image_src($photo_id, 'full');
						endif;
						$photos = array();
						if($work_photo != NULL && !empty($work_photo)):
							foreach($work_photo as  $photo_id)
								$photos[] = wp_get_attachment_image_src($photo_id, 'full');
						endif;
					?>
						<?php the_post_thumbnail(); ?>
						
						<h4><?php the_title()?></h4>
						<h5><?php echo $subtitle; ?></h5>
						
						<?php include (TEMPLATEPATH . '/inc/share.php' ); ?>
						
						<div id="slider-into-work" class="royalSlider default haszoom">		
							<ul class="royalSlidesContainer">
							<?php if(!empty($slides)): foreach($slides as $slide): ?>
								<li class="royalSlide">
									<img class="royalImage" src="<?php echo $slide[0]?>" width="100%" height="100%"/>
									<div class="royalCaption">
										<a href="<?php echo $slide[0]?>" rel="lightbox" class="zoom"></a>
									</div> 				
								</li>
							<?php endforeach; endif; ?>
							</ul>		
						</div>
						
						<aside>
						<?php 
							for($i=0; $i< count($work_field); $i++): 
								echo "<p><b>" . $work_field[ $i ] .":</b><br />". $work_value[ $i ] ."</p>";
							endfor;
						?>		
						</aside>
						<article class="container-570"><?php the_content(); ?></article>
						
						<?php if(!empty($photos)): foreach($photos as $photo): ?>
							<p><img src="<?php echo $photo[0]?>" alt="addional-image" class="addional-image"></p>
						<?php endforeach; endif; ?>
						
						<h3 class="copyright">&copy; BLOOT Architecture</h3>
						
						<?php 
							$nextPost = get_adjacent_post(false,'',false);
							if($nextPost):						
								$nextthumbnail = get_the_post_thumbnail($nextPost->ID);
								$next_post_url = get_permalink($nextPost->ID);
						?>
								<div class="thumb">
									<a href="<?php echo $next_post_url; ?>">   
										<?php echo $nextthumbnail; ?>			
									</a>
								</div>
						<?php endif; ?>
						<script>
							$(document).ready(function() {
								$("#slider-into-work").royalSlider({
									captionShowEffects:["moveleft", "fade"],
									imageScaleMode: "fill",				
									slideshowDelay:5000,				
								}); 
								if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
									jQuery(function($) {
										$("a[rel^='lightbox']").picbox({/* Put custom options here */}, null, function(el) {
											return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
										});
									});
								}								
							});		
						</script>
					</div>
					<?php endwhile; endif; ?>
					<?php include_once (TEMPLATEPATH . '/inc/language-nav.php' ); ?>
				</section>
				<?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''): ?>
			</div>
		</div>
    </div>    
	<?php include_once (TEMPLATEPATH . '/inc/menu-contact.php' ); ?>    
	<?php include_once (TEMPLATEPATH . '/inc/menu-about.php' ); ?>
</div>
<?php get_footer(); 
	else:
		set_title_header();
	endif;
?>